<?php if (!defined('THINK_PATH')) exit();?><!doctype html>
<html class="no-js fixed-layout">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Listen 美食城|美味小吃|营养丰富</title>
  <meta name="description" content="这是一个 index 页面">
  <meta name="keywords" content="index">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="icon" type="image/png" href="/Public/vendor/assets/i/favicon.png">
  <link rel="apple-touch-icon-precomposed" href="/Public/vendor/assets/i/app-icon72x72@2x.png">
  <meta name="apple-mobile-web-app-title" content="Amaze UI" />
  <link rel="stylesheet" href="/Public/vendor/assets/css/amazeui.min.css"/>
  <link rel="stylesheet" href="/Public/vendor/assets/css/admin.css">
  <link rel="stylesheet" href="/Public/vendor/nprogress/nprogress.css">

  
</head>
<body>

<!--加载动画-->
<div id="globalLoading" class="global-loading">
    <div class="global-loading-logo">
        <div id="globalLoadingAnim" class="global-loading-anim"></div>
    </div>
</div>
<!--加载动画-->
<script src="/Public/assets/admin/js/loading.js"></script>
<script>
    window.onload = function () {
        $("#globalLoading").fadeOut();
    }
</script>



<header class="am-topbar am-topbar-inverse admin-header">
    <div class="am-topbar-brand">
        <strong>Listen 美食城</strong> <small>后台管理模板</small>
    </div>

    <button class="am-topbar-btn am-topbar-toggle am-btn am-btn-sm am-btn-success am-show-sm-only" data-am-collapse="{target: '#topbar-collapse'}"><span class="am-sr-only">导航切换</span> <span class="am-icon-bars"></span></button>

    <div class="am-collapse am-topbar-collapse" id="topbar-collapse">

        <ul class="am-nav am-nav-pills am-topbar-nav am-topbar-right admin-header-list">
            <li><a href="javascript:;"><span class="am-icon-envelope-o"></span> 收件箱 <span class="am-badge am-badge-warning">5</span></a></li>
            <li class="am-dropdown" data-am-dropdown>
                <a class="am-dropdown-toggle" data-am-dropdown-toggle href="javascript:;">
                    <span class="am-icon-users"></span> <?php echo ($_SESSION[user]['username']); ?>管理员 <span class="am-icon-caret-down"></span>
                </a>
                <ul class="am-dropdown-content">
                    <li><a href="#"><span class="am-icon-user"></span> 资料</a></li>
                    <li><a href="#"><span class="am-icon-cog"></span> 设置</a></li>
                    <li><a href="<?php echo U('User/logout');?>"><span class="am-icon-power-off"></span> 退出</a></li>
                </ul>
            </li>
            <li class="am-hide-sm-only"><a href="javascript:;" id="admin-fullscreen"><span class="am-icon-arrows-alt"></span> <span class="admin-fullText">开启全屏</span></a></li>
        </ul>
    </div>
</header>


<div class="am-cf admin-main">
  <!-- sidebar start -->
  <div class="admin-sidebar am-offcanvas" id="admin-offcanvas">
    <div class="am-offcanvas-bar admin-offcanvas-bar">
        <ul class="am-list admin-sidebar-list">
            <li><a href="/admin"><span class="am-icon-home"></span> 首页</a></li>
            <li class="admin-parent">
                <a class="am-cf" data-am-collapse="{target: '#collapse-nav'}"><span class="am-icon-product-hunt am-icon-spin"></span> 商城中心
                    <span class="am-icon-angle-right am-fr am-margin-right"></span></a>
                <ul class="am-list am-collapse admin-sidebar-sub am-in" id="collapse-nav">
                    <li><a href="<?php echo U('Product/index');?>" class="am-cf"><span class="am-icon-shopping-cart"></span> 商品列表<span
                            class="am-badge am-badge-success am-margin-right am-fr"><?php echo ($product_counts); ?></span></a></li>
                    <!--<li><a href="<?php echo U('Product/add');?>"><span class="am-icon-puzzle-piece"></span> 商品管理</a></li>-->
                    <li><a href="<?php echo U('Category/index');?>"><span class="am-icon-calendar"></span> 分类管理</a></li>
                    <li><a href="<?php echo U('Gallery/index');?>"><span class="am-icon-photo"></span> 商品相册<span
                            class="am-badge am-badge-secondary am-margin-right am-fr">12</span></a></li>
                    <li><a href="<?php echo U('Advert/index');?>"><span class="am-icon-adjust"></span> 广告管理<span
                            class="am-badge am-badge-secondary am-margin-right am-fr"><?php echo ($advert_counts); ?></span></a></li>
                    <li><a href="<?php echo U('Customer/index');?>"><span class="am-icon-user-secret"></span> 会员管理<span
                            class="am-badge am-badge-secondary am-margin-right am-fr"><?php echo ($customer_counts); ?></span></a></li>
                    <li><a href="<?php echo U('Order/index');?>"><span class="am-icon-arrow-circle-o-right"></span> 订单管理<span
                            class="am-badge am-badge-success am-margin-right am-fr"><?php echo ($order_counts); ?></span></a></li>
                    <li><a href="<?php echo U('Recycle/index');?>"><span class="am-icon-refresh"></span> 商品回收站<span
                            class="am-badge am-badge-warning am-margin-right am-fr"><?php echo ($product_recycles); ?></span></a></li>
                </ul>
            </li>
            <li class="admin-parent">
                <a class="am-cf" data-am-collapse="{target: '#collapse-auth'}"><span class="am-icon-gear am-icon-spin"></span> 系统管理
                    <span class="am-icon-angle-right am-fr am-margin-right"></span></a>
                <ul class="am-list am-collapse admin-sidebar-sub am-in" id="collapse-auth">
                    <li><a href="<?php echo U('AuthSet/user_manage');?>"><span class="am-icon-user"></span> 用户管理
                        <span class="am-badge am-badge-success am-margin-right am-fr"><?php echo ($user_counts); ?></span></a></li>
                    <li><a href="<?php echo U('AuthSet/group_manage');?>"><span class="am-icon-group"></span> 用户组管理</a></li>
                    <li><a href="<?php echo U('AuthSet/rule_manage');?>" class="<?php echo ($_menu or ''); ?>"><span class="am-icon-lock"></span> 菜单与权限</a></li>
                </ul>
            </li>
        </ul>

        <div class="am-panel am-panel-default admin-sidebar-panel">
            <div class="am-panel-bd">
                <p><span class="am-icon-bookmark"></span> 公告</p>
                <p>时光静好，与君语；细水流年，与君同。—— Amaze UI</p>
            </div>
        </div>

        <div class="am-panel am-panel-default admin-sidebar-panel">
            <div class="am-panel-bd">
                <p><span class="am-icon-tag"></span> wiki</p>
                <p>Welcome to the Amaze UI wiki!</p>
            </div>
        </div>
    </div>
</div>

  <!-- sidebar end -->

  <!-- content start -->
  
    <div class="admin-content" id="app">

        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">编辑菜单与权限</strong> /
                <small>Edit Menus & Rules</small>
            </div>
        </div>

        <hr>

        <div class="am-g">

            <div class="am-u-lg-6">
                <div class="am-panel am-panel-default">
                    <div class="am-panel-bd ">
                        <form class="am-form" data-am-validator>

                            <input type="hidden" name="id" value="<?php echo ($rule["id"]); ?>">

                            <div id="_method"></div>
                            <div class="am-g am-margin-top">
                                <div class="am-u-sm-4 am-u-md-3 am-text-right">
                                    上级菜单
                                </div>
                                <div class="am-u-sm-8 am-u-md-9 am-u-end col-end">
                                    <select name="parent_id" id="parent_id">

                                        <!--<?php if(($rule["parent_id"]) == "0"): ?>-->
                                        <option value="0">顶级菜单</option>
                                        <!--<?php else: ?>-->
                                        <?php if(is_array($menus)): $i = 0; $__LIST__ = $menus;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$menu): $mod = ($i % 2 );++$i;?><option value="<?php echo ($menu["id"]); ?>"
                                            <?php if(($menu["id"]) == $rule["parent_id"]): ?>selected<?php endif; ?>
                                            ><?php echo ($menu["title"]); ?>
                                            </option>
                                            <?php if(is_array($menu["children"])): $i = 0; $__LIST__ = $menu["children"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$children): $mod = ($i % 2 );++$i;?><option value="<?php echo ($children["id"]); ?>"
                                                <?php if(($children["id"]) == $rule["parent_id"]): ?>selected<?php endif; ?>
                                                >&nbsp;&nbsp;&nbsp;&nbsp;|--<?php echo ($children["title"]); ?></option><?php endforeach; endif; else: echo "" ;endif; endforeach; endif; else: echo "" ;endif; ?>
                                        <!--<?php endif; ?>-->

                                    </select>
                                </div>
                            </div>

                            <div class="am-g am-margin-top">
                                <div class="am-u-sm-4 am-u-md-3 am-text-right">
                                    图标
                                </div>
                                <div class="am-u-sm-8 am-u-md-9 am-text-right">
                                    <div class="am-form-group am-form-icon">
                                        <i class="permission.icon"></i>
                                        <input type="text" class="am-input-sm" id="icon" value="<?php echo ($rule["icon"]); ?>"
                                               placeholder="请输入图标的class">
                                    </div>
                                </div>
                            </div>

                            <div class="am-g am-margin-top">
                                <div class="am-u-sm-4 am-u-md-3 am-text-right">
                                    菜单名称
                                </div>
                                <div class="am-u-sm-8 am-u-md-9">
                                    <input type="text" class="am-input-sm" id="title" value="<?php echo ($rule["title"]); ?>"
                                           placeholder="请输入菜单名称">
                                </div>
                            </div>

                            <div class="am-g am-margin-top">
                                <div class="am-u-sm-4 am-u-md-3 am-text-right">
                                    权限名称
                                </div>
                                <div class="am-u-sm-8 am-u-md-9">
                                    <textarea rows="4" id="name" placeholder="请输入权限名称"><?php echo ($rule["name"]); ?></textarea>
                                </div>
                            </div>

                            <div class="am-margin">
                                <button type="submit" class="am-btn am-btn-primary am-radius submit">保 存</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

  <!-- content end -->

</div>

<a href="#" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu" data-am-offcanvas="{target: '#admin-offcanvas'}"></a>


<!--[if (gte IE 9)|!(IE)]><!-->
<script src="/Public/vendor/assets/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="/Public/vendor/assets/js/amazeui.min.js"></script>
<script src="/Public/vendor/assets/js/app.js"></script>


<!--进度条-->
<script src="/Public/vendor/nprogress/nprogress.js"></script>
<script>
  $(function () {
      //进度条
      $(document).ready(function () {
          NProgress.start();
      });

      $(window).load(function () {
          NProgress.done();
      });
  })
</script>


    <script>
        $(function () {
            //ajax编辑
            $('.submit').click(function () {
                var info = {
                    id: $('input:hidden').val(),
                    parent_id: $('#parent_id').val(),
                    icon: $('#icon').val(),
                    title: $('#title').val(),
                    name: $('#name').val()
                };

                $.ajax({
                    type: 'POST',
                    url: "<?php echo U('edit_rule');?>",
                    data: info,
                    success: function (info) {
                        if (info.status == 1) {
                            alert(info.msg);
                            location.href = "<?php echo U('AuthSet/rule_manage');?>";
                        } else {
                            alert(info.msg);
                        }
                    }
                });
                return false;
            })
        })
    </script>


</body>
</html>